package com.imooc.t;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class TestHttpClient {
    public static void main(String[] args) {
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<String> forEntity = restTemplate.getForEntity(
            "http://www.baidu.com?q={a}",
            String.class,
            "1"
        );
        String body = forEntity.getBody();
        System.out.println(body);

        String forObject = restTemplate.getForObject(
            // https://www.baidu.com/s?wd=1&rsv_spt=1&rsv_iqid=0xd4dc3b6600002b3b&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_dl=tb&rsv_sug3=1&rsv_sug1=1&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&inputT=229&rsv_sug4=229
            "http://www.baidu.com?q={a}",
            String.class,
            "1"
        );

    }
}
